# data file for the Fltk User Interface Designer (fluid)
version 1.0110 
header_name {.h} 
code_name {.cc}
decl {\#include <FL/fl_ask.H>} {selected public
} 

decl {\#include <stdio.h>} {public
} 

decl {\#include <stdlib.h>} {public
} 

decl {\#include "../Params/PresetsArray.h"} {} 

decl {\#include "../Params/Presets.h"} {public
} 

class PresetsUI_ {} {
  Function {refresh()} {open return_type {virtual void}
  } {
    code {;} {}
  }
  Function {~PresetsUI_()} {open return_type virtual
  } {
    code {;} {}
  }
} 

class PresetsUI {} {
  Function {PresetsUI()} {} {
    code {p=NULL;
make_window();} {}
  }
  Function {~PresetsUI()} {} {
    code {copywin->hide();delete(copywin);
pastewin->hide();delete(pastewin);} {}
  }
  Function {make_window()} {} {
    Fl_Window copywin {
      label {Copy to Clipboard/Preset}
      xywh {190 173 265 430} type Double box THIN_UP_BOX color 238 hide modal
    } {
      Fl_Browser copybrowse {
        callback {int val=o->value();
if (val!=0){
   presetname->cut(0,presetname->maximum_size());
   presetname->insert(o->text(val));
};}
        xywh {10 25 245 320} type Select
      }
      Fl_Button copypbutton {
        label {Copy to Preset}
        callback {const char *tmp=presetname->value();
if (tmp!=NULL) {
        if (strlen(tmp)>0){
           p->copy(tmp);
	   copywin->hide();
        };
};}
        xywh {145 355 110 20} box THIN_UP_BOX
      }
      Fl_Button copybutton {
        label {Copy to Clipboard}
        callback {p->copy(NULL);
copywin->hide();}
        xywh {25 385 90 35} box THIN_UP_BOX align 192
      }
      Fl_Button {} {
        label Cancel
        callback {copywin->hide();}
        xywh {160 385 80 35} box THIN_UP_BOX align 192
      }
      Fl_Box {} {
        label {Type:}
        xywh {10 5 40 15} labelsize 11 align 20
      }
      Fl_Box copytypetext {
        xywh {50 5 205 15} box FLAT_BOX color 238 labelfont 1 labelsize 11 align 20
      }
      Fl_Input presetname {
        callback {const char *tmp=o->value();
if (tmp==NULL) tmp="";
if (strlen(tmp)>0) {
	copybutton->deactivate();
	copypbutton->activate();
} else {
	copybutton->activate();
	copypbutton->deactivate();
};}
        xywh {10 355 130 20} when 1
      }
    }
    Fl_Window pastewin {
      label {Paste from Clipboard/Preset}
      xywh {463 173 265 430} type Double box THIN_UP_BOX color 238 hide modal
    } {
      Fl_Browser pastebrowse {
        callback {if (o->value()==0) {
	pastepbutton->deactivate();
	deletepbutton->deactivate();
}else{
	pastepbutton->activate();
	deletepbutton->activate();
};}
        xywh {10 25 245 320} type Hold
      }
      Fl_Button pastepbutton {
        label {Paste from Preset}
        callback {int n=pastebrowse->value();
if (n!=0) p->paste(n);
pastewin->hide();
pui->refresh();}
        xywh {10 355 160 20} box THIN_UP_BOX
      }
      Fl_Button pastebutton {
        label {Paste from Clipboard}
        callback {p->paste(0);
pastewin->hide();
pui->refresh();}
        xywh {25 385 90 35} box THIN_UP_BOX align 192
      }
      Fl_Button {} {
        label Cancel
        callback {pastewin->hide();}
        xywh {160 385 80 35} box THIN_UP_BOX align 192
      }
      Fl_Box pastetypetext {
        xywh {55 5 200 15} box FLAT_BOX color 238 labelfont 1 labelsize 11 align 20
      }
      Fl_Box {} {
        label {Type:}
        xywh {15 5 40 15} labelsize 11 align 20
      }
      Fl_Button deletepbutton {
        label Delete
        callback {int n=pastebrowse->value();

if (this->p_is_PresetArray) {
    PresetsArray *pre = dynamic_cast<PresetsArray *>(p);
    if (n!=0) pre->deletepreset(n);
    rescanArray();
} else {
    if (n!=0) p->deletepreset(n);
    rescan();
}} selected
        xywh {180 355 75 20} box THIN_UP_BOX
      }
    }
  }
  Function {copy(Presets *p)} {} {
    code {copybutton->activate();
copypbutton->deactivate();


this->p=p;
this->pui=NULL;
bool but=(Fl::event_button()!=FL_LEFT_MOUSE);
presetname->cut(0,presetname->maximum_size());

if (but) p->copy(NULL);
   else {
        rescan();
	copytypetext->label(&p->type[1]);
	copywin->show();
   };} {}
  }
  Function {paste(Presets *p,PresetsUI_ *pui)} {} {
    code {this->p=p;
this->pui=pui;
bool but=(Fl::event_button()!=FL_LEFT_MOUSE);
pastepbutton->deactivate();
deletepbutton->deactivate();

if (but) {
	p->paste(0);
	pui->refresh();
} else {
        rescan();
	pastetypetext->label(&p->type[1]);
	if (p->checkclipboardtype()) pastebutton->activate();
		else pastebutton->deactivate();
	this->p_is_PresetArray = false;
	pastewin->show();
   };} {}
  }
  Function {copy(Presets *p,int n)} {} {
    code {PresetsArray *pre = dynamic_cast<PresetsArray *>(p);
if(pre)
    pre->setelement(n);
copyArray(p);} {}
  }
  Function {paste(Presets *p,PresetsUI_ *pui,int n)} {} {
    code {PresetsArray *pre = dynamic_cast<PresetsArray *>(p);
if(pre)
    pre->setelement(n);
pasteArray(p,pui);} {}
  }
  Function {rescan()} {} {
    code {copybrowse->clear();
pastebrowse->clear();
p->rescanforpresets();

for (unsigned int i=0;i<presetsstore.presets.size();i++){
   std::string name=presetsstore.presets[i].name;
   if(name.empty())
       continue;
   copybrowse->add(name.c_str());
   pastebrowse->add(name.c_str());
};} {}
  }
  decl {Presets *p;} {public local
  }
  decl {PresetsUI_ *pui;} {public local
  }
  Function {copyArray(Presets *p)} {open
  } {
    code {PresetsArray *pre = dynamic_cast<PresetsArray *>(p);

copybutton->activate();
copypbutton->deactivate();

this->p=p;
this->pui=NULL;
bool but=(Fl::event_button()!=FL_LEFT_MOUSE);
presetname->cut(0,presetname->maximum_size());

if (but) pre->copy(NULL);
   else {
        rescanArray();
	copytypetext->label(&pre->type[1]);
	copywin->show();
   };} {}
  }
  Function {pasteArray(Presets *p,PresetsUI_ *pui)} {open
  } {
    code {PresetsArray *pre = dynamic_cast<PresetsArray *>(p);

this->p=p;
this->pui=pui;
bool but=(Fl::event_button()!=FL_LEFT_MOUSE);
pastepbutton->deactivate();
deletepbutton->deactivate();

if (but) {
	pre->paste(0);
	pui->refresh();
} else {
        rescanArray();
	pastetypetext->label(&pre->type[1]);
	if (pre->checkclipboardtype()) pastebutton->activate();
		else pastebutton->deactivate();
	this->p_is_PresetArray = true;
	pastewin->show();
   };} {}
  }
  Function {rescanArray()} {open
  } {
    code {PresetsArray *pre = dynamic_cast<PresetsArray *>(p);

copybrowse->clear();
pastebrowse->clear();
pre->rescanforpresets();

for (unsigned int i=0;i<presetsstore.presets.size();i++){
   std::string name=presetsstore.presets[i].name;
   if(name.empty())
       continue;
   copybrowse->add(name.c_str());
   pastebrowse->add(name.c_str());
};} {}
   }
  decl {bool p_is_PresetArray;} {public
  }
} 

decl {PresetsUI *presetsui;} {public
} 
